package com.cloud.DrugManagement.client;

import com.cloud.DrugManagement.config.MultipartSupportConfig;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author zhozixiong
 * @date 2023/03/17
 */
@FeignClient(value = "minio-service", configuration = MultipartSupportConfig.class)
@RequestMapping("/minio")
public interface MinioClient {

    /**
     *  上传单张图片
     */
    @PostMapping(value = "/uploadPicture", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
    String uploadPicture(@RequestPart("file") MultipartFile file, @RequestParam("bucketName") String bucketName);

    /**
     *  上传多张图片
     */
    @PostMapping(value = "/uploadPictures", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
    List<String> uploadPictures(@RequestPart("files") MultipartFile[] files, @RequestParam("bucketName") String bucketName);

    /**
     * 查看图片
     */
    @GetMapping("/downloadPicture")
    Response downloadPicture(@RequestParam("bucketName") String bucketName, @RequestParam("objectName") String objectName);
}
